// app/model/friends.js
"use strict";
module.exports = (app) => {
    const crypto = require('crypto');
  const { STRING, INTEGER, DATE, ENUM, TEXT } = app.Sequelize;
  // 配置（重要：一定要配置详细，一定要！！！）
  const Manager = app.model.define("manager", {
    id: {
        type: INTEGER(20),
        primaryKey: true,
        autoIncrement: true,
      },
      username: {
        type: STRING(30),
        allowNull: false,
        defaultValue: "",
        comment: "用户名",
        unique: true,
      },
      password: {
        type: STRING,
        allowNull: false,
        defaultValue: "",
        comment: "密码",
        set(val){
          const hmac = crypto.createHash("sha256", app.config.crypto.secret);
          hmac.update(val);
          let hash= hmac.digest("hex");
          this.setDataValue("password",hash)
        }
      },
      note: {
        type: STRING,
        defaultValue: "",
        comment: "简历",
      },

      avatar: {
        type: STRING,
        defaultValue: "",
        comment: "头像",
      },
      name: {
        type: STRING,
        defaultValue: "",
        comment: "名称",
      },
      notename: {
        type: STRING,
        defaultValue: "",
        comment: "简历名",
      },
      
      created_time: DATE,
      updated_time: DATE,
      
  });
 
  return Manager;
};